home *** CD-ROM | disk | FTP | other *** search
/ Mac100% 1998 November / MAC100-1998-11.ISO.7z / MAC100-1998-11.ISO / スクリーンセーバーファクトリー / DarkSide of the Mac 5.0.2 / SampleFaders / Invert.c < prev    next >
Text File  |  1994-08-25  |  3KB  |  135 lines

  1. /*
  2.     DarkSide 3.0 - a 7.0 dependant, system clean expandable screen saver.
  3.     
  4.     copyright ゥハ1990, 1991, 1992 by Tom Dowdy
  5.     All rights reserved.
  6.  
  7.     This is a simple fader that shows how to create a fader for DarkSide.
  8. */
  9. #include <Memory.h>
  10. #include <Windows.h>
  11. #include <Dialogs.h>
  12. #include <Errors.h>
  13.  
  14. #include "Fader.h"
  15.  
  16. /* ------------------------------------------------------------------------    */
  17. /* GLOBAL VARIABLES */
  18. /* ------------------------------------------------------------------------    */
  19. long        gNextInvert;            // next time to invert the screens
  20.  
  21. /* ------------------------------------------------------------------------    */
  22. OSErr    PreflightFader(MachineInfoPtr machineInfo, long *minTicks, long *maxTicks)
  23. /*
  24.     Called when fader is starting up - before window has been created
  25. */
  26. {
  27. #pragma unused (machineInfo)
  28.     
  29.     // no need to go faster than this!
  30.     *minTicks = 1;
  31.     *maxTicks = 15;
  32.     
  33.     return(noErr);
  34.     
  35. } // PreflightFader
  36.  
  37. /* ------------------------------------------------------------------------    */
  38. OSErr    InitializeFader(MachineInfoPtr machineInfo)
  39. /*
  40.     Called when fader is starting up - after window has been created
  41. */
  42. {
  43.     short            screenIndex;
  44.     ScreenInfoPtr    pScreen;
  45.         
  46.     pScreen = &machineInfo->theScreens[0];
  47.     for (screenIndex = 0; screenIndex < machineInfo->numScreens; ++screenIndex)
  48.         {
  49.         PaintRect(&pScreen->bounds);
  50.             
  51.         ++pScreen;
  52.         }
  53.         
  54.     gNextInvert = TickCount();
  55.     
  56.     return(noErr);
  57.     
  58. } // InitializeFader
  59.  
  60. /* ------------------------------------------------------------------------    */
  61. OSErr    IdleFader(MachineInfoPtr machineInfo)
  62. /*
  63.     Called during idle time for the fader
  64. */
  65. {
  66.     short            screenIndex;
  67.     ScreenInfoPtr    pScreen;
  68.     
  69.  
  70.     if (TickCount() > gNextInvert)
  71.         {
  72.         pScreen = &machineInfo->theScreens[0];
  73.         for (screenIndex = 0; screenIndex < machineInfo->numScreens; ++screenIndex)
  74.             {
  75.             if (Random() & 0x01)
  76.                 InvertRect(&pScreen->bounds);
  77.                 
  78.             ++pScreen;
  79.             }
  80.  
  81.         gNextInvert = TickCount() 
  82.             + (9-machineInfo->faderSettings->theShorts[0]) * 10;
  83.         }
  84.         
  85.     return(noErr);
  86.     
  87. } // IdleFader
  88.  
  89.  
  90. /* ------------------------------------------------------------------------    */
  91. OSErr    DisposeFader(MachineInfoPtr machineInfo)
  92. /*
  93.     Called when the fade is tearing down
  94. */
  95. {
  96. #pragma unused (machineInfo)
  97.  
  98.     return(noErr);
  99.     
  100. } // DisposeFader
  101.  
  102. /* ------------------------------------------------------------------------    */
  103. OSErr    UpdateFader(MachineInfoPtr machineInfo)
  104. /*
  105.     Called when there is an update event for our fade window.
  106. */
  107. {
  108.     // erase the screen
  109.     InitializeFader(machineInfo);
  110.     return(noErr);
  111.     
  112. } // UpdateFader
  113.  
  114. /* ------------------------------------------------------------------------    */
  115. OSErr    HitFader(MachineInfoPtr machineInfo, DialogPtr dPtr, short itemHit, short itemOffset)
  116. /*
  117.     Called when there is an event in the settings dialog.  itemHit will be
  118.     the item the user has selected, or 0 when the dialog is being set up.
  119.     
  120.     itemHit - itemOffset will allow you to determine which item in your dialog
  121.     list this corresponds to.
  122.     
  123.     If you don't wish to do any special processing of this event, simply return
  124.     "fnfErr" and the standard effect will take place.
  125.     
  126.     WARNING: Your A5 world may not be set up at this point, so don't try to use
  127.     your global variables!!!
  128. */
  129. {
  130. #pragma unused (machineInfo, dPtr, itemHit, itemOffset)
  131.  
  132.     return(fnfErr);
  133.     
  134. } // HitFader
  135.